﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    class BaseObject
    {
        public enum OBJ_TYPE { OBJ_NONE, OBJ_PLAYER, OBJ_ENEMY };

        public OBJ_TYPE m_ObjectType;
        public Texture2D m_Texture;
        public float m_fFrame;
        public int m_nMaxFrame;
        public Vector2 m_Position;
        public Vector2 m_Velocity;
        public SpriteEffects m_Direction;
        public Vector2 m_AnimOrigin;

        public BaseObject()
        {
            m_ObjectType = OBJ_TYPE.OBJ_NONE;
        }

        virtual public void Update(float deltaT , KeyboardState LastKeyState) 
        {
            m_Position.Y += m_Velocity.Y * deltaT;
            m_Position.X += m_Velocity.X * deltaT;

            m_fFrame += deltaT * ((m_Velocity.X > 0.0f) ? m_Velocity.X : -m_Velocity.X) / 25.0f;
            if (m_fFrame >= m_nMaxFrame)
                m_fFrame = 0;
        }

        virtual public void Render(SpriteBatch spriteBatch, Camera cam)
        {
            spriteBatch.Draw(m_Texture, new Rectangle((int)m_Position.X, (int)m_Position.Y, 128, 128), new Rectangle(128 * (int)m_fFrame + (int)m_AnimOrigin.X, (int)m_AnimOrigin.Y, 128, 128), Color.White, 0.0f, new Vector2(64, 128), m_Direction, 0.0f);
        }

        virtual public void CollisionResponse(BaseObject other, Rectangle collRect)
        {
            
        }
    }
}
